package com.lengxf.redis.service;


import lombok.AllArgsConstructor;
import org.springframework.data.geo.Point;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

import java.util.List;


/**
 * redis坐标服务操作类
 *
 * @Author Lengxf
 */
@Component
@AllArgsConstructor
@SuppressWarnings({"rawtypes", "unchecked"})
public class RedisGeoService {

    private RedisTemplate redisTemplate;

    /**
     * 保存点位信息
     *
     * @author Lengxf
     */
    public <T> Long savePoint(String key, T name, Point point) {
        return redisTemplate.opsForGeo().add(key, point, name);
    }

    /**
     * 获取点位信息
     *
     * @author Lengxf
     */
    public <T> List<Point> getPoint(String key, T... name) {
        return redisTemplate.opsForGeo().position(key, name);
    }


}
